using System;
using System.Globalization;
using jSLCore.Client.Presentation.jBinding;

namespace jSLApp.Client.Converters
{
    public class EmptyTextToEmptyParargaph : jChainConverter
    {
        private const string EmptyParagraph = @"<Section xml:space=""preserve"" HasTrailingParagraphBreakOnPaste=""False"" xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""><Paragraph FontSize=""14"" FontFamily=""Calibri"" Foreground=""#FF000000"" FontWeight=""Normal"" FontStyle=""Normal"" FontStretch=""Normal"" TextAlignment=""Left""></Paragraph></Section>";

        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (string.IsNullOrEmpty(value as string))
                return
                    EmptyParagraph;
            return value;
        }

        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (string.IsNullOrEmpty(value as string))
                return
                    EmptyParagraph;
            return value;
        }
    }
}